package gui.keyActions;

import gui.DrawPanel;

import java.awt.Color;
import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;

import dados.Curva;

public class IncrementCurveAction extends AbstractAction{
	
	private DrawPanel target;
	private Color[] colors;
	
	public IncrementCurveAction(DrawPanel target) {
		super();
		this.target = target;
		colors = new Color[]{Color.BLUE, Color.CYAN, Color.GREEN, Color.MAGENTA, Color.ORANGE, Color.PINK, Color.ORANGE, Color.RED, Color.YELLOW};
	}

	@Override
	public void actionPerformed(ActionEvent arg0) {
		Curva c = new Curva(colors[this.target.getDraw().getNextColor()]);
		this.target.getDraw().incrementColor();
		if (this.target.getDraw().getNextColor() >= this.colors.length){
			this.target.getDraw().setNextColor(0);
		}
		
		c.setCurveVisible(this.target.isAllCurvesVisible());

		c.setPolygonalVisible(this.target.isAllPolygonalsVisible());
		c.setControlPointsVisible(this.target.isAllControlPointsVisible());
		c.setAnimated(this.target.getDraw().isAnimatedPolygonals());
		this.target.getDraw().addCurve(c);
		this.target.getDraw().setCurveIndex(this.target.getDraw().getCurves().size() - 1);
	}

}
